// 宿舍信息
import instance from "@/util/axios.js"
/**
 * 获取宿舍楼信息
 * @param {number} id 宿舍楼id 
 * @returns 宿舍楼信息对象
 */
export const getDormitory = async (id) =>
    await instance.get("/api/currency/getDormitory", {
        params: {
            id
        }
    })

/**
 * 
 * @param {number} peopleNum 几人间 
 * @returns 
 */

export const getRoomRate = async (peopleNum) =>
    await instance.get(`/api/super/getRoomRate/${peopleNum}`)


/**
 * 创建宿舍楼
 * @param {String} dormitoryName  宿舍楼名称
 * @param {number} floorNum 楼层数
 * @param {number} roomNum 房间数
 * @param {number} fewPeople 每间多少人
 * @param {number} RoomRateId 宿舍费id
 * @param {number} price 价格
 * @param {number} isExits 是否需要新添加宿舍费
 * @returns 
 */
export const addDormitory = async ({
        dormitoryName,
        floorNum,
        roomNum,
        fewPeople,
        RoomRateId,
        price,
        isExits
    }) =>
    await instance.post("/api/super/addDormitory", {
        dormitoryName,
        floorNum,
        roomNum,
        fewPeople,
        RoomRateId,
        price,
        isExits
    })


/**
 * 删除宿舍楼
 * @param {number} id  宿舍楼id
 */
export const delDormitory = async (id) =>
await instance.delete(`/api/super/delDormitory/${id}`)
/**
 * 获取楼层
 * @param {number} dormitoryId 宿舍楼id
 * @param {number} floorId 楼层id
 */
export const getFloor = async ({dormitoryId,floorId}) =>
await instance.get("/api/currency/floor",{
    params: {
        dormitoryId,
        floorId
    }
})
/**
 * 获取宿舍
 * @param {number} dormitoryId 宿舍楼id
 * @param {number} floorId 楼层id
 * @param {number} roomNoId 房间id
 */
export const getRoomNo = async ({dormitoryId,floorId,roomNoId}) =>
await instance.get("/api/currency/roomNo",{
    params: {
        dormitoryId,
        floorId,
        roomNoId
    }
}) 

/**
 * 查询未分配的宿舍
 */
export const getUnallocated = async () =>
await instance.get("/api/super/getUnallocated")